﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


[System.Serializable]
public class Quest 
{
    [SerializeField]
    private string title;

    public string MyTitle { get => title; set => title = value; }
    public string MyQLDescription { get => qLDescription; set => qLDescription = value; }
    public string MyQDDescription { get => qDDescription; set => qDDescription = value; }

    public QuestScript MyQuestScript { get; set; }
    
    public CollectObjective[] MyCollectObjectives { get => collectObjectives; }
    public bool MyIsComplete
    {
        get
        {
            foreach(Objective o in collectObjectives)
            {
                if (!o.MyIsComplete &&o.MainObj)
                {
                    return false;
                }
            }
            return true;
        }
    }

    

    [SerializeField]
    private string qLDescription;
    [SerializeField]
    private string qDDescription;
    [SerializeField]
    private CollectObjective[] collectObjectives;
    // Start is called before the first frame update
    void Awake()
    {
        string date = System.DateTime.Now.ToString();
       
       
    }
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
[System.Serializable]
public abstract class Objective
{
    [SerializeField]
    private int amount;
    private int currentAmount;
    [SerializeField]
    private string type;
    [SerializeField]
    private bool timeLimited;
    [SerializeField]
    private bool mainObj=true;
    [SerializeField]
    private string qDDescription;
    public bool MyIsComplete
    {
        get
        {

            return currentAmount >= amount;
        }
    }
    public int MyAmount { get => amount;  }
    public int MyCurrentAmount { get => currentAmount; set => currentAmount = value; }
    public string MyType { get => type;  }
    public bool MyTimeLimited { get => timeLimited; set => timeLimited = value; }
    public bool MainObj { get => mainObj;  }
}
[System.Serializable]
public class CollectObjective : Objective
{
    
    public void UpdateItemCount(Item item)
    {
        
        
        if (item.MyTitle.ToLower().Replace(" ", "") == MyType.ToLower().Replace(" ", ""))
        {
            MyCurrentAmount = inventoryScript.MyInstance.GetItemCount(item.MyTitle);
            QuestLog.MyInstance.UpdateCount();
            QuestLog.MyInstance.CheckCompletion();
        }
    }
}